package com.shop.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class DecimalUtil {

    public static final BigDecimal ONE_HUNDRED = new BigDecimal(100);

    public static BigDecimal percentRate(BigDecimal amount) {
        return amount.divide(ONE_HUNDRED, 2, BigDecimal.ROUND_DOWN);
    }

    public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
        return num1.divide(num2, 2, BigDecimal.ROUND_DOWN);
    }

    public static BigDecimal percent(BigDecimal num1, BigDecimal num2) {
        return num1.multiply(ONE_HUNDRED).divide(num2, 2, BigDecimal.ROUND_DOWN);
    }


    public static String str(BigDecimal amount) {
        DecimalFormat format = new DecimalFormat("0.00");
        return format.format(amount);
    }

}
